#include<iostream>
#include<stdlib.h>
#include<sys/stat.h>
#include<unistd.h>
#include<linux/stat.h>
#define FIFO_FILE "sample FIFO"

int main()
{
    FILE* fp;
    char readbuf[80];

    umask(0);
    //c创建有名管道
    mknod(FIFO_FILE,S_IFIFO|0666,0);

    while(1)
    {
        //打开有名管道道
        fp=fopen(FIFO_FILE,"r");
        //读取数据
        fgets(readbuf,80,fp);
        printf("recived string:%s\n",readbuf);
        //关闭
        fclose(fp);
    }
    return 0;
}